package devcken.net.socket;

import java.nio.ByteBuffer;

public class StateObject
{
	private TcpClient _socket;
	
	private ByteBuffer _buffer;
	
	private Header _header;
	
	public StateObject(TcpClient socket)
	{
		this._socket = socket;
	}
	
	public StateObject(TcpClient socket, int bufferSize)
	{
		this(socket);
		
		this._buffer = ByteBuffer.allocate(bufferSize);
	}

	public TcpClient getSocket()
	{
		return this._socket;
	}

	public ByteBuffer getBuffer()
	{
		return this._buffer;
	}

	public Header getHeader()
	{
		return this._header;
	}
	
	public void setBuffer(byte[] buffer)
	{
		if (buffer == null)
		{
			return;
		}
		
		this._buffer = ByteBuffer.allocate(buffer.length);
		
		this._buffer.put(buffer);
	}
	
	public void setHeader(Header header)
	{
		this._header = header;
	}
}